package ua.eug.airv1.menu;

import com.badlogic.gdx.scenes.scene2d.InputEvent;
import com.badlogic.gdx.scenes.scene2d.InputListener;

public class SideMenuListener extends InputListener {

	private float px, py;
	
	public SideMenuListener() {
		super();
	}

    public boolean touchDown (InputEvent event, float x, float y, int pointer, int button) {
    	px = x;
    	py = y;
    	System.out.println("touch started at (" + x + ", " + y + ") " + event.getListenerActor().getName());
    	return true;
    }

    public void touchUp (InputEvent event, float x, float y, int pointer, int button) {
    	if (Math.abs(x-px)+Math.abs(y-py)<30) { // if no moves on tap 
    		System.out.println("touch done at (" + x + ", " + y + ") " + event.getListenerActor().getName());
    		SideMenu.getInstance().itemClicked(event.getListenerActor().getName());
    	}
    }

}
